﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Data;
using System.Windows.Media;
using VIA.SiMoJi.Domain.Electronics;

namespace VIA.Presentation.Converters
{
    public class TrayPointStatusToBrushConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            TrayPointStatus status = (TrayPointStatus)Enum.Parse(value.GetType(), value.ToString());
            switch (status)
            {
                case TrayPointStatus.Empty: return Brushes.WhiteSmoke;
                case TrayPointStatus.OK: return Brushes.GreenYellow;
                case TrayPointStatus.NG: return Brushes.Red;
                case TrayPointStatus.CompletedOK: return Brushes.Green;
                case TrayPointStatus.CompletedNG: return Brushes.Red;
                default:
                    break;
            }
            return Brushes.WhiteSmoke;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value == null || parameter == null || !(bool)value)
            {
                return DependencyProperty.UnsetValue;
            }

            return Enum.Parse(targetType, parameter.ToString());
        }
    }
}
